home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-16 | 1.5 KB | 59 lines |
- import java.lang.*;
- import java.io.*;
- import java.util.*;
-
- public class Implementor extends java.lang.Object
- implements AdventureConstants
- {
- // This is the Control Centre of the Adventure - the
- // main non-visual unit. It creates the Adventure and
- // looks after other essential tasks such as
- // saving and restoring.
-
- // Create the Adventure
- private Adventure Adv = new Adventure();
-
- Implementor() {
- }
-
- // HANDLE THE ADVENTURE OBJECT
- Adventure getAdv() {
- return Adv;
- }
-
- // Save
- String SaveAdv() {
- // return String indicating success (or otherwise) of Save operation
- String s = "\nFile Saved";
- try {
- FileOutputStream fos = new FileOutputStream("Adv.sav");
- ObjectOutputStream oos = new ObjectOutputStream( fos );
- oos.writeObject( Adv );
- oos.flush(); // write out any buffered bytes
- }
- catch (Exception e) {
- s = "\nSerialization Error! Can't save data.";
- }
- return s;
- }
-
- // Load
- String LoadAdv() {
- // return String indicating success (or otherwise) of Load operation
- String s = "\nFile Loaded";
- try {
- FileInputStream fis = new FileInputStream("Adv.sav");
- ObjectInputStream ois = new ObjectInputStream( fis );
- Adv = (Adventure) ois.readObject( );
- }
- catch (Exception e) {
- s = "\nSerialization Error! Can't load data.";
- }
- return s;
- }
-
-
-
-
-
- }